﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentValidation;
using NUnit.Framework;
using Spaanjaars.ContactManager.Infrastructure.Validation;
using Spaanjaars.ContactManager.Model;

namespace Spaanjaars.ContactManager.Tests.Domain
{
    [TestFixture]
    public class When_validating_a_name
    {
        [Test]
        public void The_firstname_cannot_be_empty()
        {
            var name = new Name(string.Empty, "Millett");

            var nameValidator = new NameValidator();

            var brokenRules = nameValidator.Validate(name);

            Assert.That(brokenRules.Errors.Count().Equals(1));
        }

        [Test]
        public void The_lastname_cannot_be_empty()
        {
            var name = new Name("Scott", string.Empty);

            var nameValidator = new NameValidator();

            var brokenRules = nameValidator.Validate(name);

            Assert.That(brokenRules.Errors.Count().Equals(1));
        }

        [Test]
        public void The_middlename_can_be_empty()
        {
            var name = new Name("Scott", string.Empty, "Millett");

            var nameValidator = new NameValidator();

            var brokenRules = nameValidator.Validate(name);

            Assert.That(brokenRules.Errors.Count().Equals(0));
        }        
    }
}
